﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Vds2465Telegrams
{
	public class UserData_42_SecurityCode : UserData
	{
		#region private member variables

		private readonly byte _lowValue;
		private readonly byte _highValue;

		#endregion private member variables

		#region constructor

		public UserData_42_SecurityCode(byte lowValue, byte highValue)
			: base(UserData.UserData42SecurityCode)
		{
			_lowValue = lowValue;
			_highValue = highValue;
		}

		#endregion constructor

		#region getters

		public byte LowValue { get { return _lowValue; } }
		public byte HighValue { get { return _highValue; } }
		
		#endregion getters

		#region ToString, Equals, GetHashCode

		public override int GetHashCode()
		{
			int hashCode = base.GetHashCode();
			hashCode ^= _lowValue;
			hashCode ^= _highValue;

			return hashCode;
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("(");
			stringBuilder.Append(ToStringProperties());
			stringBuilder.Append(")");

			return stringBuilder.ToString();
		}

		internal override string ToStringProperties()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append(base.ToStringProperties());

			stringBuilder.Append(", ");

			stringBuilder.Append("LowValue='");
			stringBuilder.Append(LowValue);
			stringBuilder.Append("'");

			stringBuilder.Append(", ");

			stringBuilder.Append("HighValue='");
			stringBuilder.Append(HighValue);
			stringBuilder.Append("'");

			return stringBuilder.ToString();
		}

		public override bool Equals(object obj)
		{
			Type objType = obj.GetType();
			if (this.GetType() == objType)
			{
				UserData_42_SecurityCode userData2Compare = obj as UserData_42_SecurityCode;
				return EqualsProperties(userData2Compare);
			}

			return false;
		}

		internal bool EqualsProperties(UserData_42_SecurityCode userData2Compare)
		{
			if (base.EqualsProperties(userData2Compare))
			{
				if (LowValue == userData2Compare.LowValue)
				{
					return (HighValue == userData2Compare.HighValue);
				}

				return false;
			}

			return false;
		}

		#endregion ToString, Equals, GetHashCode
	}
}
